<!-- login.php
      The main purpose of this function is to take user input either
       allow or disallow access to sensible information and programs
        located on the website. It has an encryption/decryption function
         created by halojoy http://www.phpbuilder.com/board/showthread.php?t=10326721-->

<!-- Takes in:
     Returns: _SESSION['Username'] and access to admin. -->


<?php

//This next section displays either the textfields required for the user to input his username and
//password or a message welcoming the user to our website
//First checks to see if the session doesnt have a username.
if (!isset($_SESSION['Username']) || ($_SESSION['Username'] == "Guest" ))
{
        //If it does not, two text fields are displayed, one for username and the other for password.
        //The input types are text and password respectively. The third and last input is the login
        //button.
	echo(
		"<form action=\"testlog.php\" method=\"post\">
		<div class=\"bar1\"> <input type=\"text\" value=\"\" name=\"Username\" /> 	</div>
		<div class=\"bar2\"> <input type=\"password\" value=\"\" name=\"Password\" /> 		</div>
		<div class=\"bar3\"> <input type=\"submit\" value=\"Login\" /> 	</div>
		</form>
		"
	);

}
//If the first if statements condition returns false, this will return true (unless something has gone
//terribly... terribly wrong.) This checks to see if the session has a username.
elseif (isset($_SESSION['Username']) )
{
       //If it does, a welcome messages is displayed. It displays Hello and then the sessions username
       //There is also a submit button that calls the function to log out.
	echo(
		"<form action=\"logout.php\" method=\"post\">
		<div class=\"bar5 largebodycopy\"> Hello ".$_SESSION['Username']."!</div>

		<div class=\"bar2\"> <input type=\"submit\" value=\"Log Out\" /> 	</div>
		</form>
		"
	);
}



?>
